<div class="animated fadeInRight ecommerce">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>
                        <vc:i18n name="调拨申请" namespace="allocationStorehouseApply"></vc:i18n>
                    </h5>
                    <span class="fa fa-info-circle popover-show hand" data-content="因每个仓库的审批流程不同，故调拨的商品需来自同一仓库！"></span>
                    <div class="ibox-tools" style="top:10px;">
                        <button type="button" class="btn btn-primary btn-sm" v-on:click="_goBack()">
                            <i class="fa fa-close"></i>
                            <vc:i18n name="返回" namespace="allocationStorehouseApply"></vc:i18n>
                        </button>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">
                            <vc:i18n name="仓库" namespace="allocationStorehouseApply"></vc:i18n>
                        </label>
                        <div class="col-sm-10">
                            <select class="custom-select" v-model="allocationStorehouseApplyInfo.shId"
                                    @change="_computeFlow()">
                                <option selected disabled value="">
                                    {{vc.i18n('必填，请选择仓库','allocationStorehouseApply')}}
                                </option>
                                <option v-for="(item,index) in allocationStorehouseApplyInfo.storehouses" :key="index"
                                        v-bind:value="item.shId">{{item.shName}}
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label">
                            <vc:i18n name="申请说明" namespace="allocationStorehouseApply"></vc:i18n>
                        </label>
                        <div class="col-sm-10 ">
                            <textarea v-model.trim="allocationStorehouseApplyInfo.remark"
                                      :placeholder="vc.i18n('必填，请填写申请说明','allocationStorehouseApply')"
                                      class="form-control">
                            </textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>
                        <vc:i18n name="调拨物品" namespace="allocationStorehouseApply"></vc:i18n>
                    </h5>
                    <div class="ibox-tools" style="top:10px;">
                        <button type="button" class="btn btn-primary btn-sm"
                                v-on:click="_openAllocationStorehouseModel()">
                            <i class="fa fa-search"></i>
                            <vc:i18n name="选择物品" namespace="allocationStorehouseApply"></vc:i18n>
                        </button>
                    </div>
                </div>
                <div class="ibox-content">
                    <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
                        <thead>
                        <tr>
                            <th class="text-center">
                                <vc:i18n name="物品类型" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="物品名称" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="物品规格" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="固定物品" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="源仓库" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="参考价格" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="库存" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="目标仓库" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="调拨数量" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                            <th class="text-center">
                                <vc:i18n name="操作" namespace="allocationStorehouseApply"></vc:i18n>
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="(resourceStore, index) in allocationStorehouseApplyInfo.resourceStores">
                            <td class="text-center" style="vertical-align: inherit;">
                                {{resourceStore.parentRstName ? resourceStore.parentRstName : '-'}} >
                                {{resourceStore.rstName ? resourceStore.rstName : '-'}}
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                {{resourceStore.resName}}({{resourceStore.resCode}})
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                {{resourceStore.rssName ? resourceStore.rssName : '-'}}
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">{{resourceStore.isFixedName}}</td>
                            <td class="text-center" style="vertical-align: inherit;">{{resourceStore.shaName}}</td>
                            <td class="text-center" style="vertical-align: inherit;">
                                <select class="form-control" v-model="resourceStore.timesId"
                                        @change="_changeTimesId($event, index)">
                                    <option value="" selected>
                                        {{vc.i18n('请选择价格','allocationStorehouseApply')}}
                                    </option>
                                    <option v-for="time in resourceStore.times" :value="time.timesId">
                                        {{time.price}}
                                    </option>
                                </select>
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                {{_getTimesStock(resourceStore)}}{{resourceStore.unitCodeName}}
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                <select class="custom-select" v-model="resourceStore.shzId" style="width: 70%">
                                    <option value="">
                                        {{vc.i18n('必填，请选择目标仓库','allocationStorehouseApply')}}
                                    </option>
                                    <option v-for="(item,index) in allocationStorehouseApplyInfo.storehouses"
                                            :key="index" v-bind:value="item.shId"
                                            v-if="item.shId != resourceStore.shId && item.communityId == allocationStorehouseApplyInfo.communityId">
                                        {{item.shName}}
                                    </option>
                                </select>
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                <input v-model="resourceStore.curStock" type="number"
                                       :placeholder="vc.i18n('必填，请填写调拨数量','allocationStorehouseApply')"
                                       class="form-control" style="width: 50%;display:inline; margin: auto">&nbsp;&nbsp;{{resourceStore.unitCodeName}}
                            </td>
                            <td class="text-center" style="vertical-align: inherit;">
                                <div class="btn-group">
                                    <button class="btn-white btn btn-xs"
                                            v-on:click="_openDeleteResourceStoreModel(resourceStore)">
                                        <vc:i18n name="取消调拨" namespace="allocationStorehouseApply"></vc:i18n>
                                    </button>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="10">
                                <ul class="pagination float-right"></ul>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="row" v-if="allocationStorehouseApplyInfo.audit.assignee == '-2'">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>
                        <vc:i18n name="审批人" namespace="allocationStorehouseApply"></vc:i18n>
                    </h5>
                    <div class="ibox-tools" style="top:10px;"></div>
                </div>
                <div class="ibox-content">
                    <div class="form-group row">
                        <label class="col-sm-2 col-form-label text-right">
                            <vc:i18n name="审批人" namespace="allocationStorehouseApply"></vc:i18n>
                        </label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"
                                   :placeholder="vc.i18n('必填，请选择审批人','allocationStorehouseApply')" disabled
                                   v-model="allocationStorehouseApplyInfo.audit.staffName">
                        </div>
                        <div class="col-sm-2">
                            <button class="btn btn-white " type="button" v-on:click="chooseStaff()">
                                <i class="fa fa-search"></i> 选择
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <vc:create path="property/selectStaff"></vc:create>
    <div class="row">
        <div class="col-md-10"></div>
        <div class="col-md-2 " style="margin-bottom:10px; text-align:right">
            <button type="button" class="btn btn-primary" style="margin-left:10px;" v-on:click="_submitApply()">
                <vc:i18n name="提交" namespace="allocationStorehouseApply"></vc:i18n>
            </button>
        </div>
    </div>
    <vc:create path="common/chooseResourceStore" emitChooseResourceStore="allocationStorehouseApply"
               emitLoadData="allocationStorehouseApply">
    </vc:create>
</div>